<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<%include("/common/include.html"){}%>
		<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
		<style type="text/css">
		/* 	ul{
				height:auto;
				width:100%;
				padding:10px;
			}
			ul li{
				width:230px;
				display:inline-block;
			} */
		</style>
	</head>
	<body class="easyui-layout">
	<div data-options="region:'north',split: true,title:'快速查询'" style="height:200px;padding:10px;">
	<!-- <input id="orgid"  type="hidden" value="${orgid!}"> -->
		<form id="vehicleStatisticFrom"  >
			<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">开始日期</label>
				<input id = "startTime" name="_query.startTime" value='${date(),dateFormat="yyyy-MM-dd"}' class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center" 
					data-options="editable: false,icons:[{
	                       iconCls:'icon-clear',
	                       handler: function(e){
	                           $(e.data.target).datetimespinner('clear');
	                       }
	                   }]"/>
				</div>
			<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">结束日期</label>
				<input id = "endTime" name="_query.endTime" value='${date(),dateFormat="yyyy-MM-dd"}' class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center" 
					data-options="editable: false,icons:[{
	                       iconCls:'icon-clear',
	                       handler: function(e){
	                           $(e.data.target).datetimespinner('clear');
	                       }
	                   }]"/>
			</div>
			<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">注册机构</label>
				<input id="organ" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px;border-radius:3px" onclick="showMenu(); return false;" class="textbox" value="${curOrgan.name! }"/>
				<input name="_query.ORGANIDS" id="organIds" type="hidden" value="${curOrgan.ids! }">
				<input  id="initOrganName" type="hidden" value="${curOrgan.name! }">
				<input  id="initOrgan" type="hidden" value="${curOrgan.ids! }">
			</div>
			
			
			<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">号牌号码</label>
				<input  id="hphm" name="_query.NEWHPHM" class=" easyui-textbox theme-textbox-radius" style="width:212px;height:32px;text-align:center"/>
			</div>
			
			<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">车辆识别代号</label>
				<input  id="clsbdh" name="_query.CLSBDH" class=" easyui-textbox theme-textbox-radius" style="width:212px;height:32px;text-align:center"/>
			</div>
			<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
				<label class="label-top" style="width: 100%; display: block;">所有人性质</label>
				<select name="_query.OWNERTYPE" class=" easyui-combobox theme-textbox-radius" id = "ownertype" style="width:212px;height:32px;text-align:center" data-options="editable: false">
					<option value="">全部</option>
					<option value="个人">个人</option>
					<option value="企业">企业</option>
				</select>
			</div>
			
			
			
			<div style="float:left;margin-top: 16px;margin-right: 10px;">
				<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'"  style="width:212px;height:32px ;float:left;margin-right: 10px;"  onclick="searchBus()">搜索</a>
			</div>
			
			<div style="float:left;margin-top: 16px;margin-right: 10px;">
				<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear'"  style="width:212px;height:32px;float:left;margin-right: 10px;"    onclick="clearsj()">清除</a>
			</div>
		</form>
		</div>
		
		<div data-options="region:'center'" style="overflow-x:hidden;">
		<table class="easyui-datagrid" id ="vehicleInfo" style="width:100%;height:auto;"></table>
		</div>
		
		
		
		<div id="menuContent" class="menuContent" style="display: none; position: absolute;z-index: 10;">
			<ul id="organSelectTree" class="ztree" style="margin-top:0;width: 200px;"></ul>
		</div>
		<script>
		
		
		var $form = $('#vehicleStatisticFrom');
		function queryVehicle(){
			$('#vehicleInfo').datagrid({
				cls: "theme-datagrid",
				title:"车辆查询",
				singleSelect: true,
				rownumbers: true, //显示序号
				fitColumns:true,
				pagination: true,
				pageSize: 10,
				url: "vehicleQuery/getList",
				queryParams: sy.serializeObject($form),
			    method: 'post',
			    collapsible:true,
			    columns:[[
							{field:'ids',title:'ids',width:10,align:'center',hidden:true},
							{field:'clsbdh',title:'车辆识别代号',width:10,align:'center'},
							{field:'cllx',title:'车辆类型',width:10,align:'center'},
							{field:'hphm',title:'号牌号码',width:10,align:'center'},
							{field:'ownername',title:'所有人名称',width:10, align:'center'},
							{field:'ownertype',title:'所有人类型',width:10, align:'center'},
							{field:'organ',title:'注册机构',width:10,align:'center'},
							{field:'registdate',title:'注册时间',width:10, align:'center'},
							{field:'businesstype',title:'正在办理业务',width:10, align:'center',
								formatter: function(value,row,index){
									if(row.businesstype == '1'){
										return  '注册登记';
									}else if(row.businesstype == '2'){
										return  '转移登记';
									}else if(row.businesstype == '3'){
										return  '变更登记';
									}else if(row.businesstype == '4'){
										return  '注销登记';
									}else if(row.businesstype == '5'){
										return  '补换号牌';
									}else if(row.businesstype == '6'){
										return  '补换证件';
									}else if(row.businesstype == '0'){
										return  '';
									}else{
										return  '其他';
									}
								}
							},
							{field:'operate',title:'详情', align:'center',
								formatter: function(value,row,index){
									/* if(row.zdyzt == '2'){ */
									return '<a onclick='+'check(\'' + row.ids + '\')'+' class='+'button-edit button-success  l-btn l-btn-small'+'><span class='+'l-btn-left'+'><span  style='+'color:red'+' class='+'l-btn-text'+'>查看</span></span></a>'
									//}
								}
								}						
							]]
			})
			
		}
		
		
		$(document).ready(function () {
			 queryVehicle();
		});
		
		function clearsj(){
			var initOrgan = $("#initOrgan").val();
			var initOrganName = $("#initOrganName").val();
			$("#hphm").textbox("clear");
			$("#clsbdh").textbox("clear");
			$("#startTime").datebox("clear");
			$("#endTime").datebox("clear");
			$("#ownertype").combobox("clear");
			$("#organIds").attr("value", initOrgan);
			$("#organ").attr("value", initOrganName);
		}
		
		function searchBus(){
			 queryVehicle();
		}
		
		function operate(){
			return '<a href="#" style="display:inline-block;height:25px;width:80px;background:#1CCE78;line-height:25px;border-radius:3px;color:#ffffff;" onclick="check()">查&nbsp;&nbsp;看</a>';
		}
		function check(ids){
			loadDialog(null,null, '车辆详情', '${cxt !}/vehicleQuery/toDetail?ids=' + ids);
		}
		</script>
		
		<script type="text/javascript">
			var setting = {
				async : {
					enable : true,
					url : '${cxt!}/common/getOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : onClick,
					onAsyncSuccess : organTreeOnAsyncSuccess
				}
			};
			var flag=0;//只初始化一次标识
			function organTreeOnAsyncSuccess(event, treeId, msg) {
				if(flag == 0){
					var organTree = $.fn.zTree.getZTreeObj("organSelectTree");
					var nodes = organTree.getNodes();
					flag = 1;
				}
			}
			function onClick(e, treeId, treeNode) {
				
				var zTree = $.fn.zTree.getZTreeObj("organSelectTree");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						if(i == (node.length-1)){
							path += node[i].name;
						}else{
							path += node[i].name + "/";
						}
						
					}
				}
				var cityObj = $("#organ");
				cityObj.attr("value", path);
				$("#organIds").attr("value", treeNode.id);
				hideMenu();
			}
			function showMenu() {
				var cityObj = $("#organ");
				var cityOffset = $("#organ").offset();
				$("#menuContent").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
		
				$("body").bind("mousedown", onBodyDown);
			}
			function hideMenu() {
				$("#menuContent").fadeOut("fast");
				$("body").unbind("mousedown", onBodyDown);
			}
			function onBodyDown(event) {
				if (!(event.target.id == "menuBtn"
						|| event.target.id == "menuContent" || $(event.target)
						.parents("#menuContent").length > 0)) {
					hideMenu();
				}
			}
			$.fn.zTree.init($("#organSelectTree"), setting);
		</script>
	</body>
</html>
